package cn.gjxblog.controller;

import cn.gjxblog.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpRequest;
import org.springframework.social.connect.web.ProviderSignInUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.ServletWebRequest;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * @author gjx
 * @version v1.0
 * @Description
 * @date 2019/1/15 16:39
 */

@Controller
public class HomePageController {

    @Autowired
    private ProviderSignInUtils providerSignInUtils;

    @RequestMapping("/index")
    public String index(){
        return "this is index";
    }

//    @RequestMapping("/home/login")
//    public String login(){
//
//        return "/index.html";
//    }


    @PostMapping("/home/regist")
    public String regist(User user, HttpServletRequest httpServletRequest){
        String userId = user.getUsername();
        providerSignInUtils.doPostSignUp(userId,new ServletWebRequest(httpServletRequest));
        return "/index.html";
    }


}
